<?php
    //任务加入队列、加入set
    function addScreenShotsTask($taskArr){
        $hkey = md5($taskArr['business'].$taskArr['redrictURL'].$taskArr['url'].$taskArr['type'].$taskArr['scrollHeight']);
        $taskArr['status'] = 1;
        $taskjson = json_encode($taskArr);
        $this->redis->redis->hSet('ScreenShotsSet',$hkey,$taskjson);
        $this->redis->redis->rPush('ScreenShotsQueue',$taskjson);
    }   

    //从队列中拿
    function getScreenShotsTask(){
        while(1){
            $info = $this->redis->blPop("ScreenShotsQueue",0);
            $taskjson = $info[1];
            $taskArr = json_decode($taskjson,true);
            $taskArr['status'] = 2
            $hkey =  md5($taskArr['business'].$taskArr['redrictURL'].$taskArr['url'].$taskArr['type'].$taskArr['scrollHeight']);
            $taskjson = json_encode($taskArr);
            $this->redis->redis->hSet("ScreenShotsSet",$hkey,$taskjson);
            return $taskjson;
        }
    }

    //判断当前参数的任务是否在redis中
    function checkScreenShotsTaskInQueue($taskArr){
        $hkey = md5($taskArr['business'].$taskArr['redrictURL'].$taskArr['url'].$taskArr['type'].$taskArr['scrollHeight'])
        $Res =  $this->redis->redis->hGet('ScreenShotsSet',$hkey);
        return $Res;
    }

    //判断当前参数的任务是否在redis中
    function getScreenShotsTaskStatus($hkey){
        $Res =  $this->redis->redis->hGet('ScreenShotsSet',$hkey);
        return $Res;
    }

    //删除set
    function delScreenShotsTask($taskjson) {
        $taskArr = json_decode($taskjson,true);
        $hkey = md5($taskArr['business'].$taskArr['redrictURL'].$taskArr['url'].$taskArr['type'].$taskArr['scrollHeight'])  
        $this->redis->redis->hDel('ScreenShotsSet',$hkey);
    }
?>